package com.ics.web.controller.travelstar.controller;

import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.AjaxResult;
import com.ics.web.controller.travelstar.domain.TbAllTiresLine;
import com.ics.web.controller.travelstar.domain.TravelstarContact;
import com.ics.web.controller.travelstar.dto.AllTiresLineDTO;
import com.ics.web.controller.travelstar.dto.TravelstarContactDTO;
import com.ics.web.controller.travelstar.service.AllTiresLineService;
import com.ics.web.controller.travelstar.service.TravelstarContactService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author shaoly
 * @description
 * @ClassName AllTiresLineController.java
 * @createTime 2024年12月13日 17:17:25
 */
@RestController
@RequestMapping("/tires/line")
@Api(value = "首页产品线列表", tags = "首页产品线列表接口")
public class AllTiresLineController extends BaseController {

    @Resource
    private AllTiresLineService lineService;


    /**
     * 产品线树结构
     */
    @ApiOperation("首页产品线树结构")
    @GetMapping("/treeList")
    public AjaxResult treeList() {
        return success(lineService.treeList());
    }

    /**
     * 获取所有父节点
     */
    @GetMapping("/getParentList")
    public AjaxResult getParentList() {
        return success(lineService.getParentList());
    }

    /**
     * 首页产品线列表
     */
    @ApiOperation("首页产品线分页")
    @GetMapping("/list")
    public AjaxResult list(AllTiresLineDTO lineDTO) {
        return success(lineService.listPage(lineDTO));
    }


    /**
     * 首页产品线详情
     */
    @ApiOperation("首页产品线详情")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(lineService.getById(id));
    }

    /**
     * 首页产品线新增
     */
    @ApiOperation("首页产品线新增")
    @PostMapping("/save")
    public AjaxResult save(@RequestBody TbAllTiresLine form) {
        return toAjax(lineService.saveOrUpdate(form));
    }


    /**
     * 首页产品线删除
     */
    @ApiOperation("首页产品线删除")
    @PostMapping("/remove")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(lineService.removeByIds(Arrays.asList(ids.split(","))));
    }

}
